package deepseek;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import util.CommonHttpUtil;


import java.util.HashMap;
import java.util.Map;

/**
 * https://github.com/ollama/ollama/blob/main/docs/api.md
 */
public class Generate {
    public static final Integer timeout = 300000;
    public static void main(String[] args) {
        String url = "http://localhost:11434/api/generate";
        HttpRequest request = HttpUtil.createPost(url);
        Map<String, String> headers = new HashMap<>();
        String authorization = "";
        headers.put("Authorization", authorization);
        request.addHeaders(headers);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("model","deepseek-r1:14b");
        jsonObject.put("prompt","你多大了？");
        jsonObject.put("stream",false);
        String body =JSONObject.toJSONString(jsonObject);
        System.out.println("入参========"+body);
        // 发送请求
        String backInfo = CommonHttpUtil.postJson(url, headers,body,timeout);
        System.out.println("出参========"+backInfo);
    }
}
